<template>
  <div class="main-page" :style="backgroundStyle">
    <div class="main">
      <div class="header">
        <div>
          <UserMenu :data="data" />
        </div>
      </div>
      <div class="content">
        <RouterView />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from "vue";
import { useRoute } from "vue-router";
import UserMenu from "@/components/UserMenu.vue";
import  TopHome from '@/assets/img/TopHome.png'
import  TopMain from '@/assets/img/TopMain.png'
import  Topset from '@/assets/img/Topset.png'
import backgroundOne from "@/assets/img/backgroundOne.png";
import background2 from "@/assets/img/background-2.png";

const data = ref([
  { id: 1, title: "我的主页", icon: "", path: "/main/PresonalPage",img: TopHome },
  { id: 2, title: "社区", icon: "", path: "/main/Community",img: TopMain},
  { id: 3, title: "设置", icon: "", path: "/main/Setting",img: Topset },
]);
const route = useRoute();
const backgroundStyle = ref({});
watch(
  route,
  (newRoute) => {
    if (newRoute.path === "/main/Community") {
      backgroundStyle.value = {
        backgroundImage: `url(${background2})`,
      };
    } else {
      backgroundStyle.value = {
        backgroundImage: `url(${backgroundOne})`,
      };
    }
  },
  { immediate: true }
);
</script>

<style scoped lang="scss">
.main-page {
  width: 100vw;
  height: 100vh;
  // background-image: url("@/assets/img/background-2.png");
  background-size: cover;
  background-position: center;
  .main {
    width: 1024px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    .header {
      width: 100%;
      display: flex;
      justify-content: flex-end;
      height: 80px;
      .imga {
        width: 40px;
        height: 40px;
        transform: rotate(90deg);
        margin-top: 8px;
        margin-right: 20px;
        cursor: pointer;
      }
      div {
        display: flex;
        margin-top: 10px;
        height: 70px;
        // width: 250px;
        justify-content: space-between;
      }
      .topNav {
        width: 100%;
        height: 60px;
        display: flex;
        justify-content: flex-end;
      }
    }
    .content {
      width: 100%;
      height: 750px;
      display: flex;
      justify-content: center;
      align-items: flex-start;
      overflow: hidden;
    }
  }
}

@media (max-width: 1230px) {
  .main-page {
    width: 1230px;
    height: 1000px;
    .main {
      width: 1024px;
      height: 1000px;
      .header {
        width: 100%;
        height: 80px;
      }
      .content {
        width: 100%;
        height: 750px;
      }
    }
  }
}
</style>
